package com.ld.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.ld.pojo.User;
import com.ld.service.UserService;
import com.ld.util.R;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("user")
public class UserController {
	@Reference
	private UserService userService;

	//0. 用户列表
	@GetMapping("list")
	public List<User> findAll(){

		return userService.findAll();
	}

	//1. 添加用户
	@PostMapping("add")
	public String add(@RequestBody User user){
		userService.add(user);
		return "add-user";
	}

	//2. 用户登录
	@RequestMapping("login")
	public R login(){
		return R.ok().data("token",1);
	}

	//3. 用户信息
	@RequestMapping("/info")
	public R info(){
		return  R.ok().data("name","admin")
				.data("avatar","https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif");
	}
}
